<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table {
        width: 300px;
        height: 200px;
        border: 1px black solid;
        border-collapse: collapse;
    }

    td {
        border: 1px black solid;
        text-align: center;

    }
</style>

<body>
    <table>
        <thead>
            <th>
                <input type="checkbox" id="btn1">
            </th>
            <th>英雄</th>
            <th>类型</th>
        </thead>
        <tbody>
            <tr>
                <td>
                    <input type="checkbox" id="btn2">
                </td>
                <td>李白</td>
                <td>刺客</td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" id="btn3">
                </td>
                <td>小乔</td>
                <td>法师</td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" id="btn4">
                </td>
                <td>鲁班</td>
                <td>智障</td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox" id="btn5">
                </td>
                <td>梦琪</td>
                <td>战士</td>
            </tr>
        </tbody>

    </table>
</body>

</html>
<script>
    let btn = document.querySelectorAll('input')
    btn[0].onclick = function () {
        for (let j = 1; j < 5; j++) {
            btn[j].checked = btn[0].checked
        }
    }

    for(let y=1 ; y<5 ; y++){
        btn[y].onclick = function(){
            for(let i = 1 ; i<5 ; i++){
                if (!btn[i].checked) {
                    btn[0].checked = false
                    break
                }
                btn[0].checked = true
            }
        }
    }
</script>